<template>
  <div>
    <div class="header">
      <div class="logoTitleSide">
        <img
          src="../img/logo.png"
          class="logoArea"
          alt
          style="width:25px;margin-right:10px;margin-left:8px;"
        >
        <div class="titleArea">
          <router-link to="/">
            <span class="pageTitle">80教育商城</span>
          </router-link>
        </div>
      </div>
      <div class="toolMenuSide">
        <div class="userEnterAera">
          <span>|</span>
          <span class="userEnterText" @click="mine">会员中心</span>
        </div>
        <div class="seacherAera">
          <i class="iconfont icon-search"></i>
          <span class="seacherAeraText">搜索</span>
        </div>
      </div>
    </div>
    <div class="content">
      <div class="top">
        <div>
          <i class="iconfont icon-people"></i>
          <input type="text" placeholder="请输入账号" v-model="item.loginName">
        </div>
        <div>
          <i class="iconfont icon-lock"></i>
          <input type="password" placeholder="请输入密码" v-model="item.loginKey">
        </div>
        <div class="me">
          <input type="checkbox">
          <span>记住我 （两周内免费登录）</span>
        </div>
      </div>

      <div class="zhong cleafix">
        <p @click="loginBtn">登录</p>
        <span>
          <a>忘记密码？</a>
          <a @click="zc">免费注册</a>
        </span>
      </div>

      <div class="bottom">
        <p>
          <span>第三方登录</span>
        </p>
      </div>

      <footer>
        <img src="../img/logo.png" alt>
        <p>腾讯QQ</p>
      </footer>
    </div>
  </div>
</template>

<script>
import session from "../util/session";
import { MessageBox } from "mint-ui";
import { createNamespacedHelpers } from "vuex";
const { mapState, mapMutations, mapActions } = createNamespacedHelpers("login");
export default {
  data() {
    return {
      item: {
        loginName: "",
        loginKey: ""
      }
    };
  },
  methods: {
    ...mapActions([ "doLogin"]),
    zc() {
      this.$router.push("/reg");
    },
    mine() {
      if (session.isLogin()) {
        this.$router.push("/member");
      } else {
        MessageBox.alert("请先登录!").then(action => {this.$router.push("/login")});
        // alert("请先登录");
        ;
      }
    },
    loginBtn() {
      if (this.item.loginName == "") {
        MessageBox.alert("请输入用户名!")
        // alert("请输入用户名");
        return;
      }
      if (this.item.loginKey == "") {
          MessageBox.alert("请输入密码!")
        // alert("请输入密码");
        return;
      }
      this.doLogin(this.item).then(() => {
        this.$router.push("/member");
      });
    }
  }
};
</script>

<style scoped>
.cleafix::after {
  content: "";
  display: block;
  clear: both;
}
header {
  height: 40px;
  background: #ccc;
}
.content {
  background: #fff;
  padding: 30px 37px;
}
.top div {
  width: 100%;
  height: 45px;
  line-height: 45px;
}
.top input {
  height: 40px;
  font-size: 13px;
  width: 80%;
  border: 0;
  border-bottom: 1px solid #ebebeb;
  margin-left: 10px;
  outline: none;
}
.top input:hover {
  border-bottom: 1px solid #3285ff;
}
.top i {
  font-size: 20px;
  color: #9e9e9e;
}
.me {
  color: #999;
  font-size: 13px;
}
.me input {
  width: 12px;
  height: 12px;
  margin: 0;
}
.me span {
  margin-left: 10px;
}
.zhong p {
  width: 100%;
  min-height: 40px;
  background: -webkit-gradient(
    linear,
    left top,
    right top,
    from(#56c4e7),
    to(#3285ff)
  );
  background: linear-gradient(left, #56c4e7, #3285ff);
  background-color: #3285ff;
  font-size: 20px;
  line-height: 40px;
  font-weight: 400;
  text-align: center;
  color: #fff;
  border-radius: 50px;
  margin-top: 10%;
}
.zhong span {
  float: right;
  color: #3285ff;
  font-size: 14px;
  margin-top: 2%;
}
.bottom {
  margin-top: 20%;
}
.bottom p {
  font-size: 15px;
  color: #ccc;
  text-align: center;
  position: relative;
}
.bottom p::after,
.bottom p::before {
  content: "";
  border-top: 1px solid #ccc;
  width: 30%;
  display: inline-block;
  position: absolute;
  left: 4%;
  top: 58%;
}
.bottom p::after {
  left: 66%;
}
footer {
  width: 100%;
  margin-bottom: 25px;
}
footer img {
  display: block;
  width: 52px;
  height: 52px;
  margin: 20px auto 5px;
}
footer p {
  color: #a9a9a9;
  font-size: 14px;
  text-align: center;
  padding-bottom: 5%;
}
</style>
